<template>
      <view class="">
		  <view style="margin-top:150rpx;padding-bottom: 10rpx;">
		  	<approval :listTrip = "listTrip"/>
		  </view>	
     	<!-- <view class="bottom_setup">
      		<view class="bottom_white">
      			<u-button @click="handback()" class="custom-styles" :plain="true" type="primary" text="上一步(费用预算)">
      			</u-button>
      			<u-button @click="submission()" class="custom-style" type="primary" text="提交"></u-button>
      		</view>
      	</view> -->
      </view>
</template>

<script>
	import approval from '@/workspaces/views/invest/approval'
	export default {
	components:{
		approval
	},
	props:['list','travelTrip'],
	data(){
		return{
		 	listTrip:[],
			appId: "",
			wiid: "",
			formAction: "",
			taskId: "",
			wfContext: {},
			isReadOnly: false
		}
	},
	created() {
		this.listTrip = this.list;
	},
	mounted(){
		let _this = this;
		window.myvm = _this;
		window.$urlFormVue = _this;
		
		//获取流程页面的流程上下文[实用的流程信息从这里获取]
		_this.wfContext = window.parent.myvm.wfContext;
		console.info(_this.wfContext);
		//流程应用定义ID
		var appId = Object.toQueryString("appId") || "";
		//流程实例ID
		var wiid = Object.toQueryString("wiid") || "";
		if (wiid == "") {
		  wiid = _this.wfContext.WorkflowInstanceId;
		}
		//  当前页面状态：0未有实例，2待办，3查看,4待阅
		var formAction = Object.toQueryString("formAction") || 0;
		//待办任务ID，待办时才有此参数
		var taskId = Object.toQueryString("taskId") || "";
		if (formAction > 2) {
		  _this.isReadOnly = true;
		}
		_this.appId = appId;
		_this.wiid = wiid;
		_this.formAction = formAction;
		_this.taskId = taskId;
	},
	methods:{
		//审批和驳回-工作流点击"提交"时触发此函数，返回:空字符串:工作流继续提交，返回"具体错误信息":工作流不提交
		rejectWorkflow(btnDef) {
			return "";
		},
		//作废-工作流点击"作废"时触发此函数，返回:空字符串:工作流继续提交，返回"具体错误信息":工作流不提交
		//content为作废意见
		invalidWorkflow(content) {
			return "";
		},
		//转办-工作流点击"确认转办"时触发此函数，返回:空字符串:工作流继续提交，返回"具体错误信息":工作流不提交
		//opinion:转办意见
		referredWorkflow(opinion) {
			return "";
		},
		//校验-工作流点击"提交"时触校验函数，返回:true校验通过，false校验不通过；
		//也可以返回具体的错误信息：空字符串，校验通过，返回具体错误信息校验不通过，同时弹出具体的错误信息。
		validateWorkflowForm(btnDef, callback) {
			callback("");
		},
		//暂存-工作流点击"保存"时触发此函数，返回true:工作流继续提交， false:工作流不提交
		saveWorkflow(btnDef, callback) {
			let _this= this;
			if(_this.travelTrip == "1"){//变更保存
				this.listTrip.billStatus= "0";
				_this.$lyRequest.post("/gateway/reim/mp/dbsap/busiTripmEntity/changeBusiTrip.do", _this.listTrip).then(result=>{
				  if(result.data && result.data.result == 1){
				    callback("", result.data.rows.billNo);
				  }else{
					callback(result.data.msg);
				  }
				});
			} else {
				this.listTrip.billStatus= "0";
				_this.$lyRequest.post("/gateway/reim/mp/dbsap/busiTripmEntity/saveBusiTripm.do", _this.listTrip).then(result=>{
				  if(result.data && result.data.result == 1){
				    callback("", result.data.rows.billNo);
				  }else{
					callback(result.data.msg);
				  }
				});
			}
		},
		//提交单据
		sendWorkflow(btnDef, callback) {
			let _this= this;
			if(_this.travelTrip == "1"){//变更保存
				this.listTrip.billStatus= "1";
				_this.$lyRequest.post("/gateway/reim/mp/dbsap/busiTripmEntity/changeBusiTrip.do", _this.listTrip).then(result=>{
				  if(result.data && result.data.result == 1){
				    callback("", result.data.rows.billNo);
				  }else{
					callback(result.data.msg);
				  }
				});
			} else {
				this.listTrip.billStatus= "1";
				_this.$lyRequest.post("/gateway/reim/mp/dbsap/busiTripmEntity/saveBusiTripm.do", _this.listTrip).then(result=>{
				  if(result.data && result.data.result == 1){
					callback("", result.data.rows.billNo);
				  }else{
					callback(result.data.msg);
				  }
				});
			}
		},
		upStep(btnDef, callback){
			if(this.handback()){
				callback(3);
			}
		},
		handback() {
			let _this = this;
			_this.$emit('modifyNum',2)
			return true
		},
		submission(){
			let _this = this;
			_this.listTrip.billStatus = 1;
			let url ='';
			if(_this.listTrip.changeReasion){
				url = "/gateway/reim/mp/dbsap/busiTripmEntity/changeBusiTrip.do"
			}else{
				url="/gateway/reim/mp/dbsap/busiTripmEntity/saveBusiTripm.do"
			}
			_this.$lyRequest.post(url, _this.listTrip).then(data => {
				if (data.data.result == "1") {
					if (data.data.rows) {
						
					}
				}
			});
		}
	}
	}
</script>

<style lang="scss" scoped>
	.bottom_setup {
		position: fixed;
		bottom: 30rpx;
		right: 0;
		width: 100%;
		height: 160rpx;
		background-color: white;
		margin-top: 40rpx;
		padding: 35rpx 0;
		box-sizing: border-box;
	}
	.bottom_setup{
			width: 100%;
			background-color: white;
			box-shadow: 5px -10rpx 5px 0px rgba(225, 225, 225,.4),;
			position: fixed;
			bottom: 0;
			z-index: 2;
			.bottom_white{
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: space-between;
				// height: 150rpx;
				.custom-styles{
					padding: 20rpx 30rpx;
					width: 300rpx;
					height: 100rpx;
				}
				.custom-style{
					padding: 20rpx 30rpx;
					width: 300rpx;
					height: 100rpx;
					background-color: #007aff;
				}
			}
		}
</style>
